package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.model.Customer;
import com.weipai.springboot.model.CustomerIntegral;
import com.weipai.springboot.model.CustomerReputation;
import com.weipai.springboot.model.EmployeeIncome;
import com.weipai.springboot.module.dao.CustomerDao;
import com.weipai.springboot.module.mapper.CustomerIntegralMapper;
import com.weipai.springboot.module.mapper.CustomerMapper;
import com.weipai.springboot.module.mapper.CustomerReputationMapper;
import com.weipai.springboot.module.mapper.EmployeeIncomeMapper;
import com.weipai.springboot.module.service.CenterService;
import org.apache.ibatis.annotations.Update;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author songmengqiang
 * @create 2018-08-29 18:52
 **/
@Repository
public class CustomerDaoImpl implements CustomerDao {

    @Autowired
    private CustomerMapper customerMapper;
    @Autowired
    private CustomerReputationMapper reputationMapper;
    @Autowired
    private CustomerIntegralMapper customerIntegralMapper;
    @Autowired
    private EmployeeIncomeMapper employeeIncomeMapper;

    @Override
    public Customer getCustomerByLoginName(String loginName) {
        return customerMapper.getCustomerByLoginName(loginName);
    }

    @Override
    public int getCustomerByMobile(String mobile) {
        return customerMapper.getCustomerByMobile(mobile);
    }

    @Override
    public int insert(Customer customer) {
        return customerMapper.insertSelective(customer);
    }

    @Override
    public int updateByPrimaryKey22(String mobile, String s) {
        return customerMapper.updateByPrimaryKey22(mobile, s);
    }

    //验证码验证  重置手机号
    @Override
    public int resetPhone(String customerLoginName, String customerId, String password) {
        return customerMapper.resetPhone(customerLoginName, customerId, password);
    }

    @Override
    public List<Customer> selectAllByDel(int del, String search, String sort, String way) {
        return customerMapper.selectAllByDel(del, search, sort, way);
    }

    @Override
    public Customer getCustomerById(String id) {
        return customerMapper.getCustomerById(id);
    }

    @Override
    public int updateByPrimaryKey(Customer customer) {
        return customerMapper.updateByPrimaryKeySelective(customer);
    }

    @Override
    public int updateDel(String id) {
        return customerMapper.updateDel(id);
    }

    @Override
    public int batchDeleteById(String[] id) {
        return customerMapper.batchDeleteById(id);
    }

    @Override
    public int verifyCustomerByNickname(String nickname) {
        return customerMapper.verifyCustomerByNickname(nickname);
    }

    @Override
    public int updateNicknameById(String customerId, String nickname) {
        return customerMapper.updateNicknameById(customerId, nickname);
    }

    //更改会员的等级
    @Override
    public int changeCustomerMemberLevel(String customerId, String memberLevelId, String remark) {
        return customerMapper.changeCustomerMemberLevel(customerId, memberLevelId, remark);
    }

    //更改会员的类别
    @Override
    public int changeCustomerCategory(String customerId, String categoryId) {
        return customerMapper.changeCustomerCategory(customerId, categoryId);
    }

    //更改用户信誉值的余额
    @Override
    public int updateCustomerReputation(String customerId, int reputation) {
        return customerMapper.updateCustomerReputation(customerId, reputation);
    }

    @Override
    public int saveCustomerIntegral(CustomerIntegral customerIntegral) {
        return customerIntegralMapper.insert(customerIntegral);
    }

    //用户总数量
    @Override
    public int getCustomerAmount() {
        return customerMapper.getCustomerAmount();
    }

    //我的收益
    @Override
    public List<Map<String, Object>> getMyIncomes(String customerId) {
        return employeeIncomeMapper.getMyIncomes(customerId);
    }

    @Override
    public List<Customer> getMyTeams(String adminCode) {
        return customerMapper.getMyTeams(adminCode);
    }

    @Override
    public int saveEmployeeIncome(EmployeeIncome employeeIncome) {
        return employeeIncomeMapper.insertSelective(employeeIncome);
    }

    @Override
    public List<Map<String, Object>> list(Integer start, Integer size, String type, String search) {
        return customerMapper.list(start, size, type, search);
    }

    @Override
    public Integer listByPageAmount(String type, String search) {
        return customerMapper.listByPageAmount(type, search);
    }

    @Override
    public int updateCustomerCategoryId(String customerId, String customerCategoryId) {
        return customerMapper.updateCustomerCategoryId(customerId,customerCategoryId);
    }

    @Override
    public List<Map<String, Object>> getMyIncomesList(String customerId, Integer start, Integer size, String startTime, String endTime) {
        return employeeIncomeMapper.getMyIncomesList(customerId, start, size, startTime, endTime);
    }

    @Override
    public Integer getMyIncomeAmount(String customerId, String startTime, String endTime) {
        return employeeIncomeMapper.getMyIncomeAmount(customerId, startTime, endTime);
    }

    @Override
    public Integer getEmployeeInComeMoney(String customerId, String startTime, String endTime) {
        return employeeIncomeMapper.getEmployeeInComeMoney(customerId, startTime, endTime);
    }

    @Override
    public int changeStatus(String id, Integer status) {
        return customerMapper.changeStatus(id, status);
    }

    @Override
    public List<Map<String, Object>> listByAdminCode(Integer start, Integer size, String adminCode, String search) {
        return customerMapper.listByAdminCode(start, size, adminCode, search);
    }

    @Override
    public Integer listByAdminCodeAmount(String adminCode, String search) {
        return customerMapper.listByAdminCodeAmount(adminCode, search);
    }

    @Override
    public int updateByHaveCashMoney(int hcashMoney, String customerId) {
        return customerMapper.updateByHaveCashMoney(hcashMoney,customerId);
    }

}
